package com.sayice.design.lab2_1.factory;

import com.sayice.design.lab2_1.exception.UnsupportedShapeException;
import com.sayice.design.lab2_1.shape.Circle;
import com.sayice.design.lab2_1.shape.Rectangle;
import com.sayice.design.lab2_1.shape.Shape;
import com.sayice.design.lab2_1.shape.Triangle;

/**
 * @author shubing
 */
public class ShapeFactory {
    private static final String CIRCLE = "Circle";
    private static final String RECTANGLE = "Rectangle";
    private static final String TRIANGLE = "Triangle";
    
    public static Shape getShape(String shapeName)  {
        if (CIRCLE.equalsIgnoreCase(shapeName)) {
            return new Circle();
        } else if (RECTANGLE.equalsIgnoreCase(shapeName)) {
            return new Rectangle();
        } else if (TRIANGLE.equalsIgnoreCase(shapeName)) {
            return new Triangle();
        } else {
            throw new UnsupportedShapeException();
        }
    }
}
